package com.emip.util;

import java.util.List;

import com.emip.pojo.Table;

public class TableFormat<E> {

	private Table<E> table;
	
	public TableFormat() {
		this.table = new Table<E>();
	}
	
	public <T> Table<E> formTable(long total, int page, long records, List<T> rows) {
		table.setTotal(total);
		table.setPage(page);
		table.setRecords(records);
		if (rows != null) table.setRows(wrapRows(rows));
		return table;
	}
	
	@SuppressWarnings("unchecked")
	public <T> List<E> wrapRows(List<T> rows) {
		return (List<E>) rows;
	}

	public Table<E> getTable() {
		return table;
	}

	public void setTable(Table<E> table) {
		this.table = table;
	}
	
}
